#include<bits/stdc++.h>
using namespace std;
const int N=100010;
double d[N],v[N],a[N],p[N],z[N],y[N];
double T,m,n,L,V;

int ans1=0,ans2=0;

int main()
{

      //freopen("detect.in","r",stdin);
      //freopen("detect.out","w",stdout);
      cin>>T;
      while(T--)
      {
          cin>>n>>m>>L>>V;

          for(int i=1;i<=n;i++)
          {
              cin>>d[i]>>v[i]>>a[i];
              if(a[i]!=0)
              {
                   double c=(V*V-v[i]*v[i])/(2*a[i]);
                   if(c<0)
                   {
                       z[i]=0;
                       y[i]=0;
                   }
                   else if(a>0&&(c+d[i])<L)
                   {
                       z[i]=c+d[i];
                       y[i]=L+1;
                   }
                   else if(a<0)
                   {
                       z[i]=d[i];
                       y[i]=d[i]+c;
                   }
              }
              if(a[i]==0)
              {
                  if(v[i]>V)
                  {
                      z[i]=d[i];
                      y[i]=L;

                  }
                  else if(v[i]<=V)
                  {
                      z[i]=0;
                      y[i]=0;

                  }
              }

          }
          for(int j=1;j<=m;j++)
           {
               cin>>p[j];

           }
          for(int i=1;i<=n;i++)
            for(int j=1;j<=m;j++)
            {
                   if(p[j]>z[i]&&p[j]<y[i])
                   {
                       ans1++;
                       break;
                   }

            }
if(ans1)ans2=m-1;
else ans2=m;
          cout<<ans1<<" "<<ans2<<endl;
     }
     return 0;
}
